#include <iostream>
#include <algorithm>
#include <set>
#include <vector>

using namespace std;

int main(int argc, char const *argv[])
{
    string texts[] = {"In the same gang.","In different gangs.","Not sure yet." };
    vector<int> results;
    set<int> setA;
    set<int> setB;
    bool flagA, flagB;
    char c;
    int t, n, m, x, y;
    int i, j;
    cin >> t;
    for (i = 0; i < t; i++)
    {
        setA = set<int>();
        setB = set<int>();

        cin >> n >> m;
        
        for (j = 0; j < m; j++)
        {
            cin >> c >> x >> y;
            cout << c << x << y << endl;
            if (c == 'A')
            {
                if (setA.find(x) != setA.end())
                    setB.insert(y);
                else if (setB.find(x) != setB.end())
                    setA.insert(y);
                else if (setA.find(y) != setA.end())
                    setB.insert(x);
                else if (setB.find(y) != setB.end())
                    setA.insert(x);
                else setA.insert(x), setB.insert(y);
            }
            else 
            {
                if (setA.find(x) == setA.end() && setB.find(x) == setB.end()
                 || setA.find(y) == setA.end() && setB.find(y) == setB.end())
                    results.push_back(2);
                else if (setA.find(x) != setA.end())
                    if (setA.find(y) != setA.end())
                        results.push_back(0);
                    else 
                        results.push_back(1);
                else if (setB.find(x) != setB.end())
                    if (setB.find(y) != setB.end())
                        results.push_back(0);
                    else
                        results.push_back(1);                   
            }
        }
    }
    

    for (i = 0; i < results.size(); i++)
    {
        if (!i) cout << texts[results[i]];
        cout << "\n" << texts[results[i]];
    }

    return 0;
}
